//<![CDATA[
var thumbnail_mode = "float" ; 
summary_noimg = 250; 
summary_img = 210; 
img_thumb_size = 95;
var numm_rand_post=3;

function removeHtmlTag(strx,chop){
    if(strx.indexOf("<")!=-1){
         var s = strx.split("<");
         for(var i=0;i<s.length;i++){
             if(s[i].indexOf(">")!=-1){
             s[i] = s[i].substring(s[i].indexOf(">")+1,s[i].length);
             }
         }
         strx = s.join("");
    }
    chop = (chop < strx.length-1) ? chop : strx.length-2;
    while(strx.charAt(chop-1)!=' ' && strx.indexOf(' ',chop)!=-1) chop++;
    strx = strx.substring(0,chop-1);
    return strx+'...';
}

function createTumbnail(thumbUrl,img_size) {
   var thumbnail = thumbUrl ;
   var patt0 = /s72-c/g;
   var patt1 = /s200/g;
   var patt2 = /s320/g;
   var patt3 = /s400/g;
   var patt4 = /s640/g;
   var patt5 = /s1600/g;

   if ( patt1.test(thumbnail) == true) {
       thumbnail = thumbnail.replace("s200","s"+img_size+"-c");
       return thumbnail;
   } else if (patt2.test(thumbnail) == true) {
       thumbnail = thumbnail.replace("s320","s"+img_size+"-c");
       return thumbnail;
   } else if (patt3.test(thumbnail) == true) {
       thumbnail = thumbnail.replace("s400","s"+img_size+"-c");
       return thumbnail;
   } else if (patt4.test(thumbnail) == true) {
       thumbnail = thumbnail.replace("s640","s"+img_size+"-c");
       return thumbnail;
   } else if (patt5.test(thumbnail) == true) {
       thumbnail = thumbnail.replace("s1600","s"+img_size+"-c");
       return thumbnail;
   } else if (patt0.test(thumbnail) == true) {
       thumbnail = thumbnail.replace("s72-c","s"+img_size+"-c");
       return thumbnail;
   }
}


function popTumbnail(Turl,Tsize) {
    return ('<img src="'+createTumbnail(Turl,Tsize)+'" />');
}


function createSummaryAndThumb(ID,pURL,pTitle){
    var pID = 'summary' + ID;
    var pThumb = 'thumbnail-' + ID;
    var div = document.getElementById(pID);
    var thumb = document.getElementById(pThumb);
    var imgtag = "";
    var img = div.getElementsByTagName("img");
    var summ = summary_noimg;
    if(img.length>=1) {
        imgtag = '<span style="padding:0px;"><a href="'+ pURL +'" alt="tumbnail" title="'+ pTitle +'"><img src="' + img[0].src + '" alt="thumbnails"/></a></span>';
        summ = summary_img;
    } else {
        imgtag = '';
        summ = summary_img;
    }
    thumb.innerHTML = imgtag ;
    div.innerHTML = '<div>' + removeHtmlTag(div.innerHTML,summ) + '</div>';
}
//]]>